package com.example.demo.item;

import com.example.demo.entity.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;

/**
 * @author hc
 * @version 1.0
 * @date 2020/4/15 10:58
 * @description
 */
//spring batch中需要实现ItemProcessor接口来进行批量处理读入的数据
public class PersonItemProcessor implements ItemProcessor<Person,String> {
    private static final Logger LOGGER =
            LoggerFactory.getLogger(PersonItemProcessor.class);

    @Override
    public String process(Person person) {
        String greeting = "Hello " + person.getFirstName() + " "
                + person.getLastName() + "!";

        LOGGER.info("converting '{}' into '{}'", person, greeting);
        return greeting;
    }

}
